package com.alennus.blog.rabbitMq.simple;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by pactera on 2018/9/21.
 */
public class RabbitConnetcionUtils {

    public static Connection getConnetion(){
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);
        factory.setVirtualHost("/alenus");
        factory.setUsername("Alenus");
        factory.setPassword("alenus");
        Connection connection = null;
        try {
            connection =  factory.newConnection();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return connection;
    }
}
